package com.yh.autobio.modules.adatper;

import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yh.autobio.R;
import com.yh.autobio.modules.bean.CustPhone;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * =========================
 * 版权所有，违法必究
 * 作者：john
 * <p>
 * 工程：FoodBarcode
 * <p>
 * 文件名：CustPhoneAdapter
 * <p>
 * 创建时间：2017.05.23.9:36
 * *****************************
 */
public class CustPhoneAdapter extends ListBaseAdapter<CustPhone> {

    private String mType;

    public CustPhoneAdapter(String type) {
        this.mType = type;
    }

    @Override
    protected View getRealView(int position, View convertView, ViewGroup parent) {

        ViewHolder vh = null;
        if (convertView == null || convertView.getTag() == null) {
            convertView = getLayoutInflater(parent.getContext()).inflate(
                    R.layout.item_cust_phone, null);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }
        if ("khdh".equals(mType)) {//客服电话
            vh.tvDesc.setText("客服电话");
        } else if ("ghdw".equals(mType)) {//购货单位
            vh.tvDesc.setText("购货单位");
        } else if ("xsfs".equals(mType)) {//销售方式
            vh.tvDesc.setText("销售方式");
        } else if ("ywy".equals(mType)) {//业务员
            vh.tvDesc.setText("业务员");
        } else if ("fhck".equals(mType)) {//发货仓库
            vh.tvDesc.setText("发货仓库");
        } else if ("hyb".equals(mType)) {//货运部
            vh.tvDesc.setText("货运部");
        } else if ("sklx".equals(mType)) {//收款类型
            vh.tvDesc.setText("收款类型");
        }

        CustPhone custPhone = mDatas.get(position);

        vh.tvPhone.setText(custPhone.getName());

        return convertView;
    }

    static class ViewHolder {
        @InjectView(R.id.tv_desc)
        TextView tvDesc;
        @InjectView(R.id.tv_phone)
        TextView tvPhone;
        @InjectView(R.id.ll_desc)
        LinearLayout llDesc;

        ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }
}
